import { ActionDesc } from '@/global/constant'
import { FormType } from '@/base-ui/base-form/type'
import { IModalConfig } from '@/components/page-modal/type'
import { IStandardOptions } from '@/global/type'

const getUserListModalAssignRole = (
  options: IStandardOptions[]
): IModalConfig => {
  console.log(options)
  const newOptions = options.map((item) => ({
    value: item.value,
    content: item.label
  }))

  const config = {
    modalProps: {
      title: '分配角色',
      width: 500,
      maskClosable: false,
      closable: false
    },
    formProps: {
      desc: ActionDesc.UserAssignRole,
      layout: { span: 24 },
      formConfig: {
        name: 'user-assign-role',
        size: 'small',
        labelAlign: 'right',
        labelCol: { flex: '85px' },
        colon: false
      },
      itemsConfig: [
        {
          type: FormType.Select,
          prop: 'roleId',
          name: 'roleId',
          label: '角色名',
          rules: [{ required: true }],
          select: {
            baseProps: {
              placeholder: '请选择角色'
            },
            options: newOptions
          }
        }
      ]
    }
  }

  return config as IModalConfig
}

export default getUserListModalAssignRole
